package com.akk.action;

import com.akk.business.AvsHxtPayBusiness;
import com.akk.module.avs.model.request.HxtOpenCardNotifyRequest;
import com.akk.module.avs.model.request.HxtPaymentNotifyRequest;
import com.akk.module.avs.model.request.HxtPaymentRequest;
import com.akk.module.avs.model.request.HxtSendSMSRequest;
import com.akk.utils.RestResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;


/**
 * Created by admin on 2017/11/11.
 * 恒信通
 */
@RestController
@RequestMapping("/thmlfApi/avs/hxtpay")
public class AvsHxtPayAction {

    @Autowired
    private AvsHxtPayBusiness hxtPayBusiness;


    @GetMapping("/opencardquery")
    @ApiOperation(value = "开卡状态查询",notes = "开卡状态查询", httpMethod = "GET", response = RestResponse.class)
    public RestResponse openCardQuery(String cashBindId,String orderNum,String payerId){
        return hxtPayBusiness.openCardQuery(cashBindId,orderNum,payerId);
    }

    @RequestMapping(value = "/opencardnotify",method = RequestMethod.POST)
    @ApiOperation(value = "开卡状态通知",notes = "开卡状态通知", httpMethod = "POST", response = RestResponse.class)
    public void openCardNotify(HttpServletRequest servletRequest){
        hxtPayBusiness.openCardNotify(servletRequest);
    }

    @GetMapping(value = "/orderInfo")
    public RestResponse orderInfo(String payerId,String orderNum,String card){
        return hxtPayBusiness.orderInfo(payerId,orderNum,card);
    }

    @GetMapping("/opencard")
    @ApiOperation(value = "开卡",notes = "开卡", httpMethod = "GET", response = RestResponse.class)
    public RestResponse openCard(String payerId,String cashBindId,String orderNum){
        return hxtPayBusiness.openCard(payerId,cashBindId,orderNum);
    }

    @PostMapping(value = "/quickpaycallback")
    @ApiOperation(value = "回调",notes = "回调方法",httpMethod = "POST",response = String.class)
    public String quickPayCallBack(String payerId,String orderNum, HttpServletRequest request, HttpServletResponse response){
        return hxtPayBusiness.quickPayCallBack(payerId,orderNum,request,response);
    }

    @PostMapping("/sendsms")
    @ApiOperation(value = "发送交易短信",notes = "发送交易短信", httpMethod = "POST", response = RestResponse.class)
    public RestResponse sendSMS(@RequestBody @Valid HxtSendSMSRequest request, BindingResult result){
        return hxtPayBusiness.sendSMS(request,result);
    }

    @PostMapping("/payment")
    @ApiOperation(value = "交易消费",notes = "交易消费", httpMethod = "POST", response = RestResponse.class)
    public RestResponse payment(@RequestBody @Valid HxtPaymentRequest request, BindingResult result){
        return hxtPayBusiness.payment(request,result);
    }

    @RequestMapping(value = "/paymentnotify",method = RequestMethod.POST)
    @ApiOperation(value = "代付通知",notes = "代付通知", httpMethod = "POST", response = RestResponse.class)
    public void paymentNotify(HttpServletRequest servletRequest){
        hxtPayBusiness.paymentNotify(servletRequest);
    }

    @PostMapping(value = "/paymentback")
    @ApiOperation(value = "消费通知",notes = "消费通知",httpMethod = "POST",response = String.class)
    public String paymentBack(HttpServletRequest servletRequest){
        return hxtPayBusiness.paymentBack(servletRequest);
    }

    @GetMapping(value = "/payProgressQuery")
    @ApiOperation(value = "代付查询",notes = "代付查询",httpMethod = "POST",response = String.class)
    public RestResponse payProgressQuery(String orderNum){
        return hxtPayBusiness.payProgressQuery(orderNum);
    }

}
